
package metadatabrowser;

import at.fhj.itm.metadata.Column;
import at.fhj.itm.metadata.Constraint;
import at.fhj.itm.metadata.Index;
import at.fhj.itm.metadata.MetadataItem;
import at.fhj.itm.metadata.Procedure;
import at.fhj.itm.metadata.Sequence;
import at.fhj.itm.metadata.Table;

import org.eclipse.jface.viewers.LabelProvider;
import org.eclipse.swt.graphics.Image;

/**
 *
 * @author Seuchter
 */
public class SchemaTreeLabelProvider extends LabelProvider{



    public SchemaTreeLabelProvider()
    {
        super();
    }

    @Override
    public Image getImage(Object o)
    {
        return null;
    }

    @Override
    public String getText(Object o)
    {
        if(o instanceof MetadataItem)
        {
            return ((MetadataItem) o).getName();
        }
        if(o instanceof  MetadataWrapper)
        {
            MetadataWrapper<MetadataItem> items = (MetadataWrapper<MetadataItem>)o;

            if(items.getItemClass().isAssignableFrom(Table.class))
            {
                return String.format("Tables(%d)",items.getList().size());
            }
            if(items.getItemClass().isAssignableFrom(Column.class))
            {
                return String.format("Columns(%d)",items.getList().size());
            }
            if(items.getItemClass().isAssignableFrom(Constraint.class))
            {
                return String.format("Constraint(%d)",items.getList().size());
            }
            if(items.getItemClass().isAssignableFrom(Index.class))
            {
                return String.format("Indicies(%d)",items.getList().size());
            }
            if(items.getItemClass().isAssignableFrom(Procedure.class))
            {
                return String.format("Procedures(%d)",items.getList().size());
            }
            if(items.getItemClass().isAssignableFrom(Sequence.class))
            {
                return String.format("Sequence(%d)",items.getList().size());
            }
        }

        return "NA";
    }


    @Override
    public boolean isLabelProperty(Object o, String string)
    {
        return false;
    }


}
